from ise_api_0_login_info import username, password, url_prefix, headers
import requests
from requests.auth import HTTPBasicAuth
from ise_api_1_user_getall import get_user_detail
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


# 修改ISE内部用戶狀態
def change_internal_user_password(user, new_pass):
    user_detail = get_user_detail(user)
    user_url = user_detail.get('url')
    user_data_dict = {'name': user_detail.get('username'),
                      'id': user_detail.get('id'),
                      'password': new_pass}

    r = requests.put(user_url,
                     auth=HTTPBasicAuth(username, password),
                     headers=headers,
                     json={"InternalUser": user_data_dict},
                     verify=False)
    print(r.json())


if __name__ == '__main__':
    change_internal_user_password('iseuser', 'Cisc012376')